<template>
  <div class="about">
    <button @click="update">update</button>
    <button @click="update2">update2</button>
    <button @click="fun1">调用actions</button>
    <h1>This is an about page</h1>
    <h2>{{$store.state.name}}</h2>
    <h3>{{$store.getters.lowPrice}}</h3>
    <input type="text" v-model="str">
  </div>
</template>
<script>
export default {
  name:'About',
  data() {
    return {
      str:'',
      count:1
    }
  },
  created() {
    console.log('$store',this.$store);
    // this.$store.state.name="update"
  },
  methods: {
    update(){
      this.$store.commit("updateName",this.str)
    },
    update2(){
      this.$store.commit({
        type:"updateName2",
        str:this.str  
      })
    },
    fun1(){
      //直接接收参数
      this.$store.dispatch('action1',this.count)
      this.count++
    }
  },
}
</script>
